<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="Application">
    <my-alert @myclick="appfunc" title="按钮1"></my-alert>
    <my-alert @myclick="appfunc" title="按钮2"></my-alert>
</div>
<script>
    const App = Vue.createApp({
        methods: {
            appfunc(param) {
                console.log("单击了自定义组件：" + param)
            }
        }
    })
    const alertCompent = {
        data() {
            return {
                msg: "警告框提示",
                count: 0
            }
        },
        methods: {
            click() {
                console.log("组件内部逻辑")
                this.$emit('myclick', this.title)
            }
        },
        props: ["title"],
        template: `
          <div>
            <button @click="click">{{ title }}</button>
          </div>
        `

    }
    App.component("my-alert", alertCompent)
    App.mount("#Application")
</script>
</body>
</html>
